package cn.itheima.service.user.impl;

import cn.itheima.dao.user.UserDao;
import cn.itheima.domain.Company;
import cn.itheima.domain.User;
import cn.itheima.service.user.UserService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;

    //用户全查
    public PageInfo findAll( int pageNumber, int pageSize,String company_id) {
        PageHelper.startPage(pageNumber,pageSize);
        List<User> list = userDao.findAll(company_id);
        PageInfo pageInfo = new PageInfo(list);
        return pageInfo;
    }

    //用户添加
    public void edit(User user) {
        userDao. edit(user);
    }

    @Override
    public User findById(String id) {
       User user= userDao.findById(id);
        return user;
    }

    @Override
    public void update(User user) {
        userDao.update(user);
    }

    @Override
    public void delete(String id) {
        userDao.delete(id);
    }
}
